
package top.lishuoboy.hibernate.validator.model;

import cn.hutool.core.lang.RegexPool;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import lombok.experimental.SuperBuilder;
import org.hibernate.validator.constraints.CodePointLength;
import top.lishuoboy.hibernate.validator.validate.group.DeleteById;
import top.lishuoboy.hibernate.validator.validate.group.Insert;
import top.lishuoboy.hibernate.validator.validate.group.SelectById;
import top.lishuoboy.hibernate.validator.validate.group.UpdateById;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;

/**
 * 部门
 *
 * @TableName sys_dept
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@Accessors(chain = true)
@ApiModel(description = "部门")
@TableName(value = "sys_dept")
public class SysDept implements Serializable {

    /** 部门id */
    @NotNull(groups = {DeleteById.class, UpdateById.class, SelectById.class})
    @Min(0)
    @ApiModelProperty(value = "部门id", position = 10)
    @TableId(value = "dept_id", type = IdType.AUTO)
    private Integer deptId;

    /** 部门名称 */
    @NotBlank(groups = {Insert.class})
    @CodePointLength(min = 2, max = 100)
    @Pattern(regexp = RegexPool.GENERAL_WITH_CHINESE + "{2,100}")
    @ApiModelProperty(value = "部门名称", position = 20)
    @TableField(value = "dept_name")
    private String deptName;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;
}